const env = process.env;
const targetUrl = env.VUE_APP_TARGET_URL || "http://localhost:8080"
module.exports = {
  lintOnSave: true,
  devServer: {
    port: env.VUE_APP_PORT || 3000,
    proxy: {
      "/api": {
        target: targetUrl,
        changeOrigin: true,
      },
      "invoke": {
        filter: (pathname, req)=>{
          // return pathname.match('(\/proxy)?\/?[a-zA-Z\.]+\.(img|jdn|jup|vdt|vdp)$')
          return pathname.match('^(\/proxy)(\/[1-9a-zA-Z\.]+)*(\.(img|jdn|jup|vdt|vdp))?$')
        },
        target: targetUrl,
        changeOrigin: true,
      },
      "proxy": {
        target: targetUrl,
        changeOrigin: true,
        pathRewrite: {
          "^/proxy": "",
        },
      }
    },
  },

  parallel: require("os").cpus().length > 1,

  configureWebpack: config => {
    if (env.NODE_ENV === "development") {
      config.devtool = "source-map";
    }
  },

  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
};
